package com.keshi.openplatform.payment.controller;


import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.imageio.ImageIO;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.awt.image.BufferedImage;
import java.io.IOException;

@Controller
@RequestMapping("/images")
public class ImageController {

    @RequestMapping("/payimag")
    public void getImage(HttpSession session, HttpServletResponse response) {
        BufferedImage img = (BufferedImage) session.getAttribute("img");
        try {
            ImageIO.write(img, "JPEG", response.getOutputStream());
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
